import 'package:flutter/material.dart';
import 'package:p_location/utils/rich_text_util.dart';

class RightArrowItem extends StatelessWidget {
  final String leftValue;
  final String rightValue;
  final Color rightTextColor;
  final GestureTapCallback onTap;
  final bool isMust;

  RightArrowItem(this.leftValue, this.rightValue, this.onTap,
      {this.rightTextColor = Colors.grey, this.isMust = true});

  final BoxDecoration _decoration = BoxDecoration(color:Colors.white ,
      border: Border(bottom: BorderSide(color: Colors.grey, width: 0.4)));

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
        onTap: (){
          FocusScope.of(context).requestFocus( FocusNode());
          onTap();
        },
        child: Container(
          decoration: _decoration,
//          color: Colors.white,
          padding: EdgeInsets.only(left: 20, right: 12, top: 10, bottom: 10),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              RichTextUtil.getRichText(leftValue, leftStar: isMust ? '*' : ''),
              _drawableRightText(rightValue == null ? '' : rightValue)
            ],
          ),
        ));
  }

//  _onTap(context) {
//    FocusScope.of(context).requestFocus( FocusNode());
//    return onTap;
//  }

  _drawableRightText(text) {
    return Row(
      children: <Widget>[
        Container(
          margin: EdgeInsets.only(left: 5),
          child: Text(
            text,
            style: TextStyle(fontSize: 12, color: rightTextColor),
          ),
        ),
        Icon(
          Icons.keyboard_arrow_right,
          color: Colors.grey,
        )
      ],
    );
  }
}
